home *** CD-ROM | disk | FTP | other *** search
Wrap
property pSprite, pStart, pActive, pCompleteCycles, pVector, pDestination, pOrigin, pSlid, pDirection, pAuto, pPointH, pPointV, pCycles, pPeriodBase, pPeriod on getBehaviorDescription me return "SLIDE IN/OUT" & RETURN & RETURN & "Slides a sprite from one position to another. " & "Place the sprite on stage in its ending position. " & "Then choose whether the sprite should first appear at maximum (slid in) or minimum (slid out) values, when the fading should start, the minimum and maximum slide values, the number of times it should slide, and how fast it should slide. " & "The slide can be activated automatically in the first frame, by a click on the sprite, or by sending the sprite an mSlideActivate message" & RETURN & RETURN & "PERMITTED MEMBER TYPES:" & RETURN & "animated GIF, bitmap, Flash, shape, text, vector shape" & RETURN & RETURN & "PARAMETERS:" & RETURN & "* Slide in or out?" & RETURN & "* Slide direction" & RETURN & "* What event initiates slide? (automatic, click, or message)" & RETURN & "* Number of slide cycles" & RETURN & "* Time between 'in' and 'out' positions in seconds" & RETURN & RETURN & "Set the number of slide cycles to -1 if you want an endless loop, to 0 if the slide should happen once, or to 1 to slide in and then back out." end on getBehaviorTooltip me return "Slides a sprite from one position to another." & RETURN & RETURN & "The 'in' position of the slide is determined by the sprite's position on the stage; the 'out' position is set in the Parameters dialog. " & "The 'out' position can be set by the author to be a specific point on (or off) the Stage, or it can automatically calculated as a point off the Stage relative to the 'in' position." end on beginSprite me pSlid = resolve(pSlid) pDirection = resolve(pDirection) pAuto = resolve(pAuto) mInitialize(me) end on resolve prop case prop of pSlid: choiceslist = ["In", "Out"] lookup = [#in, #out] pDirection: choiceslist = ["Point", "Top", "Bottom", "Left", "Right", "Top Left", "Top Right", "Bottom Left", "Bottom Right"] lookup = [#point, #top, #bottom, #left, #right, #topLeft, #topRight, #bottomLeft, #bottomRight] pAuto: choiceslist = ["Automatic", "Click", "Message"] lookup = [#automatic, #click, #message] end case return lookup[findPos(choiceslist, prop)] end on prepareFrame me mUpdate(me) end on mouseUp me if pAuto = #click then mActivate(me) end if end on mInitialize me pSprite = sprite(me.spriteNum) vMember = pSprite.member vMemberType = vMember.type pActive = #off pCompleteCycles = 0.5 pPeriod = pPeriodBase * 1000 pOrigin = pSprite.loc vTopDiff = pSprite.bottom - pSprite.locV vBottomDiff = pSprite.locV - pSprite.top vLeftDiff = pSprite.right - pSprite.locH vRightDiff = pSprite.locH - pSprite.right case pDirection of #point: pDestination = point(pPointH, pPointV) #top: pDestination = point(pSprite.locH, -vTopDiff) #bottom: pDestination = point(pSprite.locH, (the stage).rect.height + vBottomDiff) #left: pDestination = point(-vLeftDiff, pSprite.locV) #right: pDestination = point((the stage).rect.width + vLeftDiff, pSprite.locV) #topLeft: pDestination = point(-vLeftDiff, -vTopDiff) #topRight: pDestination = point((the stage).rect.width + vLeftDiff, -vTopDiff) #bottomLeft: pDestination = point(-vLeftDiff, (the stage).rect.height + vBottomDiff) #bottomRight: pDestination = point((the stage).rect.width + vLeftDiff, (the stage).rect.height + vBottomDiff) end case pVector = pDestination - pOrigin if pSlid = #in then pSprite.loc = pDestination else pSprite.loc = pOrigin end if if pAuto = #automatic then mActivate(me) end if end on mUpdate me if pActive <> #off then vMillis = the milliSeconds vElapsed = vMillis - pStart if vElapsed >= pPeriod then case pActive of #in: pSprite.loc = pOrigin #out: pSprite.loc = pDestination end case pActive = #off mCheckCycle(me) else vVector = pVector * vElapsed / pPeriod case pActive of #in: pSprite.loc = pDestination - vVector #out: pSprite.loc = pOrigin + vVector end case end if end if end on mActivate me if pVector <> point(0, 0) then case pSlid of #in: mSlideIn(me) #out: mSlideOut(me) end case end if end on mCheckCycle me vContinue = 0 case pCycles of (-1): vContinue = 1 0: vContinue = 0 otherwise: pCompleteCycles = pCompleteCycles + 0.5 if integer(pCompleteCycles) <= pCycles then vContinue = 1 end if end case if vContinue then if pSprite.loc = pOrigin then mSlideOut(me) else mSlideIn(me) end if end if end on mSlideIn me mSlide(me, #in) end on mSlideOut me, vTarget mSlide(me, #out) end on mSlide me, vInOut pActive = vInOut pStart = the milliSeconds end on mSlideActivate me if pAuto = #message then mActivate(me) end if end on isOKToAttach me, aSpriteType, aSpriteNum case aSpriteType of #graphic: return getPos([#text, #bitmap, #animGif, #vectorShape, #flash, #shape, #field, #picture], sprite(aSpriteNum).member.type) <> 0 #script: return 0 end case end on getPropertyDescriptionList me vStage = rect(0, 0, (the stage).rect.width, (the stage).rect.height) vPDList = [:] setaProp(vPDList, #pSlid, [#comment: "Slide in or out?", #format: #string, #default: "In", #range: ["In", "Out"]]) setaProp(vPDList, #pDirection, [#comment: "Automatic slide direction (point uses values entered below)", #format: #string, #default: "Point", #range: ["Point", "Top", "Bottom", "Left", "Right", "Top Left", "Top Right", "Bottom Left", "Bottom Right"]]) setaProp(vPDList, #pPointH, [#comment: "Point Horizontal Value", #format: #integer, #default: vStage.width / 2, #range: [#min: -vStage.width, #max: vStage.width * 2]]) setaProp(vPDList, #pPointV, [#comment: "Point Vertical Value", #format: #integer, #default: vStage.height / 2, #range: [#min: -vStage.height, #max: vStage.height * 2]]) setaProp(vPDList, #pAuto, [#comment: "Start automatically, when clicked, or by message?", #default: "Automatic", #format: #string, #range: ["Automatic", "Click", "Message"]]) setaProp(vPDList, #pCycles, [#comment: "Slide cycles (0 = one slide only, -1 = repeat forever)", #format: #integer, #default: 0, #range: [#min: -1, #max: 10]]) setaProp(vPDList, #pPeriodBase, [#comment: "Time period for slide (seconds)", #format: #float, #default: 2.0, #range: [#min: 0.25, #max: 15.0]]) return vPDList end on mPermittedMemberTypes me return [#text, #bitmap, #animGif, #vectorShape, #flash, #shape, #field, #picture] end